using UnityEditor;
using UnityEngine;

namespace QFramework.Game
{
    public partial class QGFC : ViewController
    {
        public static QGFC Instance;

        void Start()
        {
            // Code Here
            Instance = this;
            OnInit();
        }

        private void OnDestroy()
        {
            DeInit();
        }

        private void OnInit()
        {
            Resources.OnInit();
            Procedure.OnInit();
            Config.OnInit();
            Reference.OnInit();
            Intenet.OnInit();
            Audio.OnInit();
            Scene.OnInit();
            UIRoot.OnInit();
            Tool.OnInit();
            DataNode.OnInit();
            Web.OnInit();
            FileTree.OnInit();
            License.OnInit();
        }

        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.Escape))
            {
#if UNITY_EDITOR
                EditorApplication.isPlaying = false;
# else
                Application.Quit();
#endif
            }
        }

        private void DeInit()
        {
            Procedure.DeInit();
            Config.DeInit();
            Resources.DeInit();
            Reference.DeInit();
            Intenet.DeInit();
            Audio.DeInit();
            Scene.DeInit();
            UIRoot.DeInit();
            Tool.DeInit();
            DataNode.DeInit();
            Web.DeInit();
            FileTree.DeInit();
            License.DeInit();
        }
    }
}